package LC;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @ClassName LC646
 * @Description: TODO
 * @Author hl
 * @Date 2020/8/14
 * @Version V1.0
 **/
public class LC646 {

    public static void main(String[] args) {
        int [][]arr={{0,1},{0,2},{0,3}};
        Arrays.sort(arr, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1]-o2[1];
            }
        });
        System.out.println(arr[2][1]);
    }


    public int findLongestChain(int[][] pairs) {
        if(pairs==null||pairs.length==0){
            return 0;
        }
        int n=pairs.length;
        int []dp=new int [n];
        Arrays.sort(pairs, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1]-o2[1];
            }
        });
        for(int i=0;i<n;i++){
            int max=1;
            for(int j=0;j<i;j++){
                if(pairs[i][0]-pairs[j][1]>0){
                    max=Math.max(max,dp[j]+1);
                }
            }
            dp[i]=max;
        }
        Arrays.sort(dp);
        return dp[n-1];
    }
}
